home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Documents / NeXTAnswers / appkit.816 < prev    next >
Text File  |  1992-02-06  |  2KB  |  71 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fswiss Helvetica;}
  2. \paperw12940
  3. \paperh12400
  4. \margl120
  5. \margr1000
  6. {\colortbl\red0\green0\blue0;}
  7. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ul0\fs28\fc0 view object name and owner
  8. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  9. \
  10. Q:  I am using the function
  11. \b  NXGetNamedObject
  12. \b0 (const char
  13. \b  
  14. \b0\i * aname
  15. \b\i0 , 
  16. \b0 id
  17. \i  owner
  18. \i0 ) to find the 
  19. \b id 
  20. \b0 of my NXBrowser object.  
  21. \fc0 My main program containing the
  22. \b  loadNibSection:owner:
  23. \b0  was created by InterfaceBuilder and had NXApp in the 
  24. \b owner:
  25. \b0  argument.  However, passing NXApp as the owner always returns a nil 
  26. \b id
  27. \b0 . What am I doing wrong?\
  28. \
  29. A:  By default, InterfaceBuilder assigns the Application object (NXApp) as the owner of a Window, and a View's Window as the owner of that View.  Since NXBrowser is a subclass of View, you must use the NXBrowser's Window id  instead of NXApp as owner in the function 
  30. \b NXGetNamedObject()
  31. \b0 . \
  32. \
  33. Below is a code snippet for illustration:\
  34.  
  35. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f1\fs24\fc0 - appDidInit:sender\
  36. \{\
  37.     id myWindow, myBrowser;\
  38.     \
  39.         /* Get the id for the browser's window */\
  40.     myWindow = NXGetNamedObject("MyWindow", NXApp);\
  41.         /* Get the id of the browser itself */\
  42.     myBrowser = NXGetNamedObject("MyBrowser", myWindow);\
  43.     \
  44.         /* Additional browser initialization */\
  45.     [myBrowser setDelegate:self];\
  46.         /* Allow multiple selection of leaf entries */\
  47.     [myBrowser allowMultiSel:YES];\
  48.         /* Allow multiple selection of branch entries */\
  49.     [myBrowser allowBranchSel:YES];\
  50.     [myBrowser setCellClass:[CustomCell class]];\
  51.     [myBrowser loadColumnZero];\
  52.     return self;\
  53. \}\
  54.  
  55. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600 \
  56.  
  57. \f0\fs28 Note that named objects are a big performance loser because of the memory it takes to keep track of all the names of the objects. For this reason, we would recommend that you use 
  58. \b loadNibSection
  59. \b0\i :owner
  60. \b\i0 :withNames:
  61. \b0\i NO
  62. \i0  when loading in nib files.  Try to use outlets instead of named objects whenever possible.\
  63. \
  64.  
  65. \fc0 QA816\
  66. \
  67. Not Valid for 1.0\
  68. Valid for 2.0\
  69. \
  70.  
  71.